package com.imooc.queue;

import java.util.Random;

public class Main {

    public static void main(String[] args) {
        int opNum = 100000;

        Queue arrayQueue = new ArrayQueue();
        System.out.println("ArrayQueue : " + test(arrayQueue, opNum));

        Queue loopQueue = new LoopQueue();
        System.out.println("LoopQueue : " + test(loopQueue, opNum));

        Queue LinkedListQueue = new LinkedListQueue();
        System.out.println("LinkedListQueue : " + test(LinkedListQueue, opNum));
    }

    private static double test(Queue q, int opNum) {
        long start = System.currentTimeMillis();
        Random random = new Random();
        for(int i = 0; i < opNum; i++) {
            q.enqueue(random.nextInt());
        }
        for(int i = opNum; i > 0; i--) {
            q.dequeue();
        }
        long end = System.currentTimeMillis();
        return (end - start);
    }
}
